package com.xuhai.movie.controller;

import com.xuhai.movie.service.UserinfoService;
import com.xuhai.movie.util.ResultJson;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Controller;
import org.springframework.web.bind.annotation.PostMapping;
import org.springframework.web.bind.annotation.ResponseBody;

/**
 * @Author PangJunjie
 * @Date 2022/4/8/008
 */
@Controller
@ResponseBody
public class LoginController extends AbstractController {

    @Autowired
    private UserinfoService userinfoService;

    @PostMapping("/login")
    public ResultJson login(String username,String password,String uuid,String code){
        return userinfoService.login(username,password,uuid,code);
    }
    @PostMapping("/logout")
    public ResultJson logout(){
        if(getLoginUser()!=null){
            userinfoService.logout(getLoginUser().getUserId());
        }
        return ResultJson.ok();
    }

}
